package com.spic.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.spic.system.api.domain.SysDept;
import com.spic.system.domain.SysMenu;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
public class TreeSelectApp implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long value;

    /** 节点名称 */
    private String text;

    public Long getValue() {
        return value;
    }

    public void setValue(Long value) {
        this.value = value;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectApp> children;

    public TreeSelectApp()
    {

    }

    public TreeSelectApp(SysDept dept)
    {
        this.value = dept.getDeptId();
        this.text = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelectApp::new).collect(Collectors.toList());
    }

    public TreeSelectApp(SysMenu menu)
    {
        this.value = menu.getMenuId();
        this.text = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelectApp::new).collect(Collectors.toList());
    }



    public List<TreeSelectApp> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelectApp> children)
    {
        this.children = children;
    }
}
